#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

/* buttondrvtest on
 * buttondrvtest off
 */
int main(int argc, char **argv)
{
	int fd;
	int ret = 0;
	int key_value[4] = {0};
	int count = 0;
	
	fd = open("/dev/button", O_RDWR);
	if (fd < 0){
		printf("can't open!\n");
		return -1;
	}

	while(1){
		ret = read(fd, key_value, sizeof(key_value));
		if(ret < 0){
			printf(" func read() err\n");
		}else{
			if(!key_value[0] || !key_value[1] || !key_value[2] || !key_value[3]){
				printf("%04d key pressed: %d %d %d %d\n",
					count++, key_value[0], key_value[1], key_value[2]
					       , key_value[3]);
			}
		}
	}
	
	return ret;
}
